package com.goodfather.textbook.youdao.pad.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

import java.io.Serializable;

public class TextBook implements Comparable<TextBook>, Serializable, Parcelable {


    @SerializedName(value = "id")
    public String id;
    @SerializedName(value = "bookName")
    private String bookName;
    private int productionId;
    @SerializedName(value = "publishingId")
    private String publishingId;
    @SerializedName(value = "coverImageUrl")
    private String coverImageUrl;
    private String description;
    private String sort;
    @SerializedName(value = "subjectId")
    private String subjectId;
    private int gradeId;
    private String gradeName;
    private boolean isFree;
    private boolean vipFree;
    private boolean isPay;
    private boolean isSuperVip;
    @SerializedName(value = "bookTypeId")
    private int bookTypeId;
    @SerializedName(value = "recover")
    private Recover recover;
    @SerializedName("last_lesson")
    private int lastLesson;
    @SerializedName("last_page")
    private int lastPage;
    @SerializedName(value = "dataURL")
    private String dataURL;

    @SerializedName(value = "dataTryURL")
    private String dataTryURL;
    @SerializedName("publishingName")
    private String publishingName;
    @SerializedName(value = "publishingAlias")
    private String publishingAlias;
    @SerializedName("publishingSort")
    private int publishingSort;

    public String getId() {
        return id;
    }

    public String getPublishingId() {
        return publishingId;
    }

    public void setPublishingId(String publishingId) {
        this.publishingId = publishingId;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getProductionId() {
        return productionId;
    }

    public void setProductionId(int productionId) {
        this.productionId = productionId;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getCoverImageUrl() {
        return coverImageUrl;
    }

    public void setCoverImageUrl(String coverImageUrl) {
        this.coverImageUrl = coverImageUrl;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getSubjectId() {
        return subjectId;
    }

    public void setSubjectId(String subjectId) {
        this.subjectId = subjectId;
    }

    public int getGradeId() {
        return gradeId;
    }

    public void setGradeId(int gradeId) {
        this.gradeId = gradeId;
    }

    public String getGradeName() {
        return gradeName;
    }

    public void setGradeName(String gradeName) {
        this.gradeName = gradeName;
    }

    //sort 升序
    @Override
    public int compareTo(TextBook another) {
        int num = Integer.valueOf(this.sort).compareTo(Integer.valueOf(another.sort));//根据sort 升序
        return num;
    }

    public boolean isFree() {
        return isFree;
    }

    public void setFree(boolean free) {
        isFree = free;
    }

    public boolean isVipFree() {
        return vipFree;
    }

    public void setVipFree(boolean vipFree) {
        this.vipFree = vipFree;
    }

    public boolean isPay() {
        return isPay;
    }

    public void setPay(boolean pay) {
        isPay = pay;
    }

    public boolean isSuperVip() {
        return isSuperVip;
    }

    public void setSuperVip(boolean superVip) {
        isSuperVip = superVip;
    }

    public TextBook() {
    }

    public int getBookTypeId() {
        return bookTypeId;
    }

    public void setBookTypeId(int bookTypeId) {
        this.bookTypeId = bookTypeId;
    }

    public Recover getRecover() {
        return recover;
    }

    public void setRecover(Recover recover) {
        this.recover = recover;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.bookName);
        dest.writeInt(this.productionId);
        dest.writeString(this.publishingId);
        dest.writeString(this.coverImageUrl);
        dest.writeString(this.description);
        dest.writeString(this.sort);
        dest.writeString(this.subjectId);
        dest.writeInt(this.gradeId);
        dest.writeString(this.gradeName);
        dest.writeByte(this.isFree ? (byte) 1 : (byte) 0);
        dest.writeByte(this.vipFree ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isPay ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isSuperVip ? (byte) 1 : (byte) 0);
        dest.writeInt(this.bookTypeId);
        dest.writeParcelable(this.recover, flags);
        dest.writeInt(this.lastLesson);
        dest.writeInt(this.lastPage);
        dest.writeString(this.dataURL);
        dest.writeString(this.dataTryURL);
        dest.writeString(this.publishingName);
        dest.writeString(this.publishingAlias);
        dest.writeInt(this.publishingSort);
    }

    protected TextBook(Parcel in) {
        this.id = in.readString();
        this.bookName = in.readString();
        this.productionId = in.readInt();
        this.publishingId = in.readString();
        this.coverImageUrl = in.readString();
        this.description = in.readString();
        this.sort = in.readString();
        this.subjectId = in.readString();
        this.gradeId = in.readInt();
        this.gradeName = in.readString();
        this.isFree = in.readByte() != 0;
        this.vipFree = in.readByte() != 0;
        this.isPay = in.readByte() != 0;
        this.isSuperVip = in.readByte() != 0;
        this.bookTypeId = in.readInt();
        this.recover = in.readParcelable(Recover.class.getClassLoader());
        this.lastLesson = in.readInt();
        this.lastPage = in.readInt();
        this.dataURL = in.readString();
        this.dataTryURL = in.readString();
        this.publishingName = in.readString();
        this.publishingAlias = in.readString();
        this.publishingSort = in.readInt();
    }

    public static final Creator<TextBook> CREATOR = new Creator<TextBook>() {
        @Override
        public TextBook createFromParcel(Parcel source) {
            return new TextBook(source);
        }

        @Override
        public TextBook[] newArray(int size) {
            return new TextBook[size];
        }
    };

    public int getLastLesson() {
        return lastLesson;
    }

    public void setLastLesson(int lastLesson) {
        this.lastLesson = lastLesson;
    }

    public int getLastPage() {
        return lastPage;
    }

    public void setLastPage(int lastPage) {
        this.lastPage = lastPage;
    }

    public String getDataURL() {
        return dataURL;
    }

    public void setDataURL(String dataURL) {
        this.dataURL = dataURL;
    }

    public String getDataTryURL() {
        return dataTryURL;
    }

    public void setDataTryURL(String dataTryURL) {
        this.dataTryURL = dataTryURL;
    }

    public String getPublishingName() {
        return publishingName;
    }

    public void setPublishingName(String publishingName) {
        this.publishingName = publishingName;
    }

    public String getPublishingAlias() {
        return publishingAlias;
    }

    public void setPublishingAlias(String publishingAlias) {
        this.publishingAlias = publishingAlias;
    }

    public int getPublishingSort() {
        return publishingSort;
    }

    public void setPublishingSort(int publishingSort) {
        this.publishingSort = publishingSort;
    }
}